unit uFrmBreakPositions;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Grids, StdCtrls, OracleData, Oracle;

type
  TFrmBreakPositions = class(TForm)
    lbl_TOP: TLabel;
    stg_BreakPos: TStringGrid;
    OracleQuery1: TOracleQuery;
    procedure stg_BreakPosDrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState);
  private
    { Private declarations }
  public
    { Public declarations }
    procedure GetData(DataSet: TOracleDataSet);
  end;

var
  FrmBreakPositions: TFrmBreakPositions;

implementation

uses uFrmDisplay;
{$R *.dfm}

procedure TFrmBreakPositions.GetData(DataSet: TOracleDataSet);
var
  C, R: Integer;
begin
  // ERASE GRID
  for R := 1 to stg_BreakPos.RowCount - 1 do
  begin
    for C := 0 to stg_BreakPos.ColCount - 1 do
    begin
      stg_BreakPos.Cells[C, R] := '';
    end;
  end;
  stg_BreakPos.Cells[0, 0] := 'PLAYER';
  stg_BreakPos.Cells[1, 0] := 'TABLE';
  stg_BreakPos.Cells[2, 0] := 'SEAT';
  R := 1;
  while not DataSet.Eof do
  begin
    stg_BreakPos.Cells[0, R] := DataSet.FieldValues['PLAYER'];
    stg_BreakPos.Cells[1, R] := DataSet.FieldValues['TABLE_NAME'];
    stg_BreakPos.Cells[2, R] := DataSet.FieldValues['SEAT'];
    inc(R);
    DataSet.Next;
    stg_BreakPos.RowCount := R;
  end;
  stg_BreakPos.Height := (stg_BreakPos.DefaultRowHeight + stg_BreakPos.GridLineWidth)*stg_BreakPos.RowCount;
  stg_BreakPos.Top := ((self.Height - lbl_TOP.Height) div 2)-(stg_BreakPos.Height div 2);
  stg_BreakPos.Left := (self.width div 2)-(stg_BreakPos.width div 2);
end;

procedure TFrmBreakPositions.stg_BreakPosDrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState);
var
  s: string;
begin
  s := (Sender as TStringGrid).Cells[ACol, ARow];
  if ARow = 0 then
    TStringGrid(Sender).canvas.Brush.Color := TStringGrid(Sender).FixedColor
  else
    TStringGrid(Sender).canvas.Brush.Color := TStringGrid(Sender).Color;
  TStringGrid(Sender).canvas.fillrect(Rect);
  DrawText((Sender as TStringGrid).canvas.handle, Pchar(s), Length(s), Rect, dt_wordbreak or DT_CENTER);
end;

ENd.
